<?php

namespace App\Http\Controllers\Api\V1;

use App\Enums\ResponseCode;
use App\Http\Controllers\Api\AbstractApiController;
use App\Services\News\NewsService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class NewsController extends AbstractApiController
{
    /**
     * App初始化
     * @return JsonResponse
     */
    public function lists(): JsonResponse
    {
        $result = NewsService::lists();
        return $this->success(trans("success"),ResponseCode::OK,$result);
    }

    /**
     * 新闻列表
     * @param Request $request
     * @return JsonResponse
     */
    public function journalism(Request $request): JsonResponse
    {
        $page = $request->input("page",1);
        $limit = $request->input("limit",20);
        $result = NewsService::journalism($page,$limit);
        return $this->success(trans("success"),ResponseCode::OK,$result);
    }
}
